package com.tony.fileserver.dao;

import org.springframework.data.annotation.Id;

import java.util.Date;

/**
 * 较大文件映射类
 *
 * 对于文件大小大于16M的文件认为是较大文件，采用Mongodb的GridsFS存储。
 */
public class BigFileDO {
    /**
     * 主键， Mongodb中的_id字段
     */
    @Id
    private String id;

    /**
     * 文件名称
     */
    private String name;

    /**
     * 文件类型
     */
    private String contentType;

    /**
     * 文件大小
     */
    private long size;

    /**
     * 上传时间
     */
    private Date uploadDate;

    /**
     * 文件的MD5值
     */
    private String md5;

    /**
     * 文件内容
     */
    private byte[] content;

    /**
     * 文件路径
     */
    private String path;

    public BigFileDO() {
    }

    public BigFileDO(String name, String contentType, long size, String md5, byte[] content) {
        this.name = name;
        this.contentType = contentType;
        this.size = size;
        this.md5 = md5;
        this.content = content;

        this.uploadDate = new Date();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public Date getUploadDate() {
        return uploadDate;
    }

    public void setUploadDate(Date uploadDate) {
        this.uploadDate = uploadDate;
    }

    public String getMd5() {
        return md5;
    }

    public void setMd5(String md5) {
        this.md5 = md5;
    }

    public byte[] getContent() {
        return content;
    }

    public void setContent(byte[] content) {
        this.content = content;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }
}
